﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using Ninject.Modules;
using Meraz.Core.Repositories;
using Meraz.Core.Commands;
using Meraz.Core.Helpers;
using Meraz.Core.Managers;
using Meraz.Core.Factories;
using Meraz.Core.Parsers;
using Meraz.Core.Providers;
using System.Web;
using Meraz.Core.Data;

namespace Meraz.Core.Config
{
    public class LiveModule : NinjectModule 
    {
        public LiveModule(): base(){}
        public override void Load()
        {
            Bind<IAddTwitterUserCommand>().To<AddTwitterUserCommand>();
            Bind<ICreateAliasesCommand>().To<CreateAliasesCommand>();
            Bind<ICreateDomainsCommand>().To<CreateDomainsSqlCommand>();
            Bind<ICreateFramesCommand>().To<CreateFramesCommand>();
            Bind<ICreatePostCommand>().To<CreatePostCommand>();
            Bind<ICreateTopicsCommand>().To<CreateTopicsCommand>();
            Bind<ICreateTweetCommand>().To<CreateTweetCommand>();
            Bind<ICreateTwitterClientCommand>().To<CreateTwitterClientCommand>();
            Bind<ICreateTwitterUserCommand>().To<CreateTwitterUserCommand>();
            Bind<ICreateUrlsCommand>().To<CreateUrlsSqlCommand>();
            Bind<ICreateUrlRedirectCommand>().To<CreateUrlRedirectSqlCommand>();
            Bind<IGetBlogCommand>().To<GetBlogCommand>();
            Bind<IGetLinkCommand>().To<GetLinkCommand>();
            Bind<IGetPostCommand>().To<GetPostCommand>();
            Bind<IGetPosterCommand>().To<GetPosterCommand>();
            Bind<IParsePostCommand>().To<ParsePostCommand>();
            Bind<IRemoveTwitterStudyCommand>().To<RemoveTwitterStudyCommand>();
            Bind<IRemoveTwitterUserCommand>().To<RemoveTwitterUserCommand>();
            Bind<ISaveBlogStudiesCommand>().To<SaveBlogStudiesCommand>();
            Bind<ISaveBlogStudyCommand>().To<SaveBlogStudyCommand>();
            Bind<ISaveDomainsCommand>().To<SaveDomainsCommand>();
            Bind<ISaveIssueCommand>().To<SaveIssueCommand>();
            Bind<ISaveLinkCommand>().To<SaveLinkCommand>();
            Bind<ISavePostCommand>().To<SavePostCommand>();
            Bind<ISavePosterCommand>().To<SavePosterCommand>();
            Bind<ISaveTweetCommand>().To<SaveTweetCommand>();
            Bind<ISaveTwitterStudyCommand>().To<SaveTwitterStudyCommand>();
            Bind<ISaveTwitterUserCommand>().To<SaveTwitterUserCommand>();
            Bind<ISaveUrlRedirectCommand>().To<SaveUrlRedirectCommand>();

            Bind<INetworkHelper>().To<NetworkHelper>();
            Bind<MyWebClient>().To<MyWebClient>().WithPropertyValue("UserAgent", "Mozilla/5.0 (Windows; Windows NT 5.1; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4");

            Bind<DomainManager>().ToSelf();
            Bind<FileManager>().ToSelf();
            Bind<PostManager>().ToSelf();
            Bind<TopicManager>().ToSelf();
            Bind<TwitterManager>().ToSelf();
            Bind<IOptionManager>().To<OptionManager>();
            Bind<IFacebookManager>().To<FacebookManager>();

            Bind<ITweetValuesParser>().To<TweetValuesParser>();
            Bind<IFacebookBoardParser>().To<FacebookBoardParser>();

            Bind<ICustomMembershipProvider>().To<CustomMembershipProvider>();
            Bind<ICustomRoleProvider>().To<CustomRoleProvider>();

            Bind<IAliasRepository>().To<AliasRepository>();
            Bind<IBlogRepository>().To<BlogRepository>();
            Bind<IBlogStudyRepository>().To<BlogStudyRepository>();
            //example of loading xml file
            //Bind<IBlogStudyRepository>().To<BlogStudyRepository>().WithConstructorArgument("fileName", ConfigHelper.BlogStudyDataFile);

            Bind<PetaPoco.Database>().ToSelf().WithConstructorArgument("connectionStringName", "mysql");

            Bind<IFacebookTopicBoardRepository>().To<FacebookTopicBoardRepository>();
            Bind<IFacebookTopicPostLinkRepository>().To<FacebookTopicPostLinkRepository>();
            Bind<IFacebookTopicPostRepository>().To<FacebookTopicPostRepository>();
            Bind<IFacebookTopicRepository>().To<FacebookTopicRepository>();


             
            Bind<IDomainRepository>().To<DomainRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IFrameRepository>().To<FrameRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IIssueRepository>().To<IssueRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ILinkRepository>().To<LinkRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IPersonRepository>().To<PersonRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IPostRepository>().To<PostRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IPosterRepository>().To<PosterRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IMemberRepository>().To<MemberRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IMemberRoleRepository>().To<MemberRoleRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IRoleRepository>().To<RoleRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITopicRepository>().To<TopicRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITweetRepository>().To<TweetRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterClientRepository>().To<TwitterClientRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterLinkRepository>().To<TwitterLinkRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterMentionRepository>().To<TwitterMentionRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterStudyRepository>().To<TwitterStudyRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterTagRepository>().To<TwitterTagRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<ITwitterUserRepository>().To<TwitterUserRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IUrlRepository>().To<UrlRepository>().WithConstructorArgument("context", MerazContext.Instance);
            Bind<IUrlRedirectRepository>().To<UrlRedirectRepository>().WithConstructorArgument("context", MerazContext.Instance);

            Bind<IObjectFactory>().To<ObjectFactory>();
        }
    }
}
